package com.atguigu.gmall.item.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @ author     ：廖传港
 * @ date       ：Created in 2021/1/14 10:56
 * @ description：准备线程池
 * @ modified By：
 * @ ersion:
 */
@Configuration
public class ThreadConfig {
    //创建对象并放到Spring容器中
    @Bean
    public ThreadPoolExecutor threadPoolExecutor() {
        return new ThreadPoolExecutor(
                10,
                20,
                60L,
                TimeUnit.SECONDS,                     //单位为秒
                new ArrayBlockingQueue<>(10)  //创建队列，队列长度为10
        );
    }
}